package wymiana.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import wymiana.domain.DGroup;
import wymiana.domain.UploadedFiles;
import wymiana.domain.User;

@Repository
public class GroupDao extends GenericDao<DGroup> {

	@Autowired
	public GroupDao(SessionFactory sf) {
		super(DGroup.class, sf);
	}

	public DGroup getGroupById(Integer id) {
		DGroup dGroup = (DGroup) getById(id);
		return dGroup;
	}

	public List<DGroup> getMyGroup(User u) {
		List<DGroup> list = getHibernateTemplate()
				.find("select gr from DGroup gr left join gr.users us where gr.createUser=? or us = ?",
						u, u);

		return list;
	}
}
